<template>
  <!--  合同筛选-->
  <div class="contract-filter">
    <div class="contract-filter__search">
      <el-input v-autoFocus placeholder="请输入合同名称" v-model="filterListData[0].value[0]" clearable :suffix-icon="Search" />
    </div>
    <div class="contract-filter__buttons">
      <el-button type="primary" class="buttons-cancel" link size="default" @click="handelReset">重置</el-button>
      <el-button type="primary" class="buttons-confirm" size="default" @click="handelConfirm">确定</el-button>
    </div>
  </div>
</template>

<script setup>
import { ref, watch } from "vue";
import { Search } from "@element-plus/icons-vue";

const props = defineProps({
  filterList: {
    type: Array,
    default: () => [
      {
        filterId: "contract_name",
        compare: "like",
        value: [""]
      }
    ]
  }
});
const emit = defineEmits(["handelFilterData"]);
const filterListData = ref([]);

watch(
  () => props.filterList,
  newVal => {
    filterListData.value = [...newVal];
  },
  { deep: true, immediate: true }
);

const handelReset = () => {
  filterListData.value[0].value = [""];
  emit("handelFilterData", filterListData.value);
};
const handelConfirm = () => {
  emit("handelFilterData", filterListData.value);
};
</script>

<style scoped lang="scss">
@import "contractName";
</style>
